import sys
from PyQt5.QtWidgets import QApplication, QWidget, QGridLayout, QLabel 
from PyQt5.QtGui import QPixmap
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
 
class ImageGrid(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()
 
    def initUI(self):
        # 创建一个网格布局
        self.grid = QGridLayout()
 
        # 创建4个图片标签，并设置它们的图片
        label = QLabel(self)

        for i in range(2):
            for j in range(2):
                hbox = QHBoxLayout()
                label = QLabel(self)
                pixmap = QPixmap('/media/chyang/data/dataset/detect/MixFormer/lasot/airplane/airplane-1/img/00000001.jpg')  # 替换为图片路径
                label.setPixmap(pixmap)
                
                self.s1 = QScrollBar()
                self.s1.setMaximum(255)
                self.s1.sliderMoved.connect(self.sliderval)
                hbox.addWidget(self.s1)
                hbox.addWidget(label)
                self.grid.addLayout(hbox, i, j)
                
                
        hbox = QHBoxLayout()
        
        self.l1 = QLabel("拖动滑动条去改变颜色")
        self.l1.setFont(QFont("Arial",16))
        self.s1 = QScrollBar()
        self.s1.setMaximum(255)
        self.s1.sliderMoved.connect(self.sliderval)
        self.s2 = QScrollBar()
        self.s2.setMaximum(255)
        self.s2.sliderMoved.connect(self.sliderval)
        self.s3 = QScrollBar()
        self.s3.setMaximum(255)
        self.s3.sliderMoved.connect(self.sliderval)


 
        # 设置窗口的布局为网格布局
        self.setLayout(self.grid)
 
        # 设置窗口的大小
        self.setGeometry(300, 300, 400, 300)
        self.setWindowTitle('Image Grid')
        self.show()
 
    def sliderval(self):
        print( self.s1.value(),self.s2.value(), self.s3.value() )
        palette = QPalette()
        c = QColor(self.s1.value(),self.s2.value(), self.s3.value(),255)
        palette.setColor(QPalette.Foreground,c)
        self.l1.setPalette(palette)
if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = ImageGrid()
    sys.exit(app.exec_())